package cn.tedu.cwfw.ff.service.impl;

import cn.tedu.cwfw.ff.mapper.FfMapper;
import cn.tedu.cwfw.ff.pojo.dto.FfQuery;
import cn.tedu.cwfw.ff.pojo.dto.FfSaveParam;
import cn.tedu.cwfw.ff.pojo.entity.Ff;
import cn.tedu.cwfw.ff.pojo.vo.FfVO;
import cn.tedu.cwfw.ff.service.FfService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Slf4j
@Service
public class FfServiceImpl implements FfService {
    @Autowired
    FfMapper ffMapper;

    @Override
    public void insertFf(FfSaveParam ffSaveParam) {
        log.debug("关注业务，参数：{}",ffSaveParam);
        Ff ff = new Ff();
        BeanUtils.copyProperties(ffSaveParam,ff);
        ff.setCreateTime(new Date());
        ffMapper.insert(ff);
    }

    @Override
    public void deleteFf(Long fansId) {
        log.debug("取消关注业务，参数：{}",fansId);
        ffMapper.deleteById(fansId);
    }

    @Override
    public List<FfVO> selectFf(FfQuery ffQuery) {
        log.debug("查询关注信息业务，参数：{}",ffQuery);
        List<FfVO> list = ffMapper.selectFf(ffQuery);
        return list;
    }

    @Override
    public List<FfVO> selectFans(FfQuery ffQuery) {
        log.debug("查询粉丝信息业务，参数：{}",ffQuery);
        List<FfVO> list = ffMapper.selectFans(ffQuery);
        return list;
    }

}
